package com.songcha.module_mine.ui.fragment.message.my_comment

import android.app.Application
import androidx.databinding.BaseObservable
import androidx.lifecycle.MutableLiveData
import com.songcha.library_base.interfaces.IApiResult
import com.songcha.library_base.mvvm.base.BaseViewModel
import com.songcha.library_network.bean.BaseBean
import com.songcha.module_mine.bean.MyBookCommentDataBean

class MessageMyCommentViewModel(app: Application):BaseViewModel<MessageMyCommentRepository>(app) {
    val myCommentList=MutableLiveData<MutableList<MyBookCommentDataBean.MyBookCommentBean>>()
    val delMyCommentState=MutableLiveData<Boolean>()

    fun getMyCommentList(){
        handleApiDataObserver(repository!!.getMyCommentList(),object:IApiResult<MyBookCommentDataBean>{
            override fun onSuccess(bean: MyBookCommentDataBean) {
                myCommentList.value=bean.data
            }

            override fun onError(e: Throwable) {

            }
        })
    }

    fun delMyComment(commentId:Int){
        handleApiDataObserver(repository!!.delMyComment(commentId),object:IApiResult<BaseBean>{
            override fun onSuccess(bean: BaseBean) {
                delMyCommentState.value=true
            }

            override fun onError(e: Throwable) {
                delMyCommentState.value=false
            }
        })
    }

}